'''
执行测试用例并生成测试报告
1.导包
2.创建测试套件
3.设置创建测试报告的文件路径
4.以二进制形式打开文件
5.创建文件流steam = f 写入信息到文件内
6.runner.run()执行生成爆报告
'''
import time
import unittest
from lib.HTMLTestRunner import HTMLTestRunner
from app import BASE_DIR
from script.test01_login import TestLogin
from script.test02_emp import TestEmp

suite = unittest.TestSuite()
# makeSuite(TestLogin)封装测试用例
# 把封装好的测试用例添加到测试套件内
suite.addTest(unittest.makeSuite(TestLogin))
suite.addTest(TestEmp("test01_list"))
# suite.addTest(unittest.makeSuite(TestEmp))
report = BASE_DIR + "/report/ihrm_login_report-{}.html".format(time.strftime("%Y%m%d-%H%M%S"))
with open(report, "wb") as f:
    runner = HTMLTestRunner(stream=f, title="ihrm登录修改员工测试报告")
    runner.run(suite)
